-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

=============================================================================
FreeBSD-EN-22:05.tail                                           Errata Notice
                                                          The FreeBSD Project

Topic:          tail -F fails to follow some types of log rotation

Category:       core
Module:         tail
Announced:      2022-01-11
Affects:        FreeBSD 13.0
Corrected:      2021-03-18 20:12:24 UTC (stable/13, 13.0-STABLE)
                2022-01-11 18:15:01 UTC (releng/13.0, 13.0-RELEASE-p6)

For general information regarding FreeBSD Errata Notices and Security
Advisories, including descriptions of the fields above, security
branches, and the following sections, please visit
<URL:https://security.FreeBSD.org/>.

I.   Background

tail(1) displays the last part of a file, and can wait for and print any data
appended to the file.  As of FreeBSD 13.0, tail(1) runs in capability mode
via Capsicum.

II.  Problem Description

When comparing the inode number of the current file to the file tail(1) has
open (in order to detect log rotation), tail(1) compared the inode number of
the already open file descriptor, rather than the file that currently has the
filename that was passed to tail(1).

III. Impact

When using tail(1)'s -F flag to follow a log file through log rotation,
depending on the type of log rotation performed, tail(1) may continue to
follow the original file after it is renamed, rather than detecting the
rotation and re-opening the original filename, and then following the new log
file.

The rotated log is usually never written to after it is rotated, causing
tail(1)'s -F flag to not perform its intended function.

IV.  Workaround

No workaround is available.

V.   Solution

Upgrade your system to a supported FreeBSD stable or release / security
branch (releng) dated after the correction date.

Perform one of the following:

1) To update your system via a binary patch:

Systems running a RELEASE version of FreeBSD on the amd64, i386, or arm64
platforms can be updated via the freebsd-update(8) utility:

# freebsd-update fetch
# freebsd-update install

2) To update your system via a source code patch:

The following patches have been verified to apply to the applicable
FreeBSD release branches.

a) Download the relevant patch from the location below, and verify the
detached PGP signature using your PGP utility.

# fetch https://security.FreeBSD.org/patches/EN-22:05/tail.patch
# fetch https://security.FreeBSD.org/patches/EN-22:05/tail.patch.asc
# gpg --verify tail.patch.asc

b) Apply the patch.  Execute the following commands as root:

# cd /usr/src
# patch < /path/to/patch

c) Recompile the operating system using buildworld and installworld as
described in <URL:https://www.FreeBSD.org/handbook/makeworld.html>.

VI.  Correction details

This issue is corrected by the corresponding Git commit hash or Subversion
revision number in the following stable and release branches:

Branch/path                             Hash                     Revision
- -------------------------------------------------------------------------
stable/13/                              8c59e863e2c0    stable/13-n244979
releng/13.0/                            60cacd2e41e1  releng/13.0-n244771
- -------------------------------------------------------------------------

Run the following command to see which files were modified by a
particular commit:

# git show --stat <commit hash>

Or visit the following URL, replacing NNNNNN with the hash:

<URL:https://cgit.freebsd.org/src/commit/?id=NNNNNN>

To determine the commit count in a working tree (for comparison against
nNNNNNN in the table above), run:

# git rev-list --count --first-parent HEAD

VII. References

The latest revision of this advisory is available at
<URL:https://security.FreeBSD.org/advisories/FreeBSD-EN-22:05.tail.asc>
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEE/A6HiuWv54gCjWNV05eS9J6n5cIFAmHd1f0ACgkQ05eS9J6n
5cKySw/8DUfeI4ku+36DJjnqTt+SGSqP7CLon8tNneD3MeuXxHewHfF9quVqlW5C
9qaCAJZztpinCvg9u2YXXZbbaZ6FPJKwjrOspo85/ZkodbXXtNkzfIHHVauE0+AH
BbHYAMcAUjDgvUaApKRVkUUYODRtzlra2qqpA3ITzK4+vo3WYMmFA78uR6j6TYvN
CWkXOEXPGjcMfmaLFtO7udfOs7//0+RaE4X15Ep+tWD+XZlgBF9kNqQ0jLOE6Dio
mgJmlmHBNXPNAKud8VjLiEaJ0fhgy5q+9E+UEwol+XW/1HTH4ZMgXyPVenl7O1wH
jyZhygc+sV3RK1P3ZC6Ecrm7Ktugtx9urmCOC8/isg/SVBbi1fj+hSeTY3tIrUHr
yxtHS7aelPVENxHaRbHW1bJI5O4G0FH0KiLIMHkCg8/9LmDvdozpGqozLijXVaaf
KGJ5Xt3qT3udbQP0T0yrmd5yusO75FLS/NnOrrCinQj8gB+355gaEeB58lWH2ndT
EqfhS4ey4MM86nrxJrzxBymVlqfGmdNtfkl/HubsBy0qnJ6OWKwom3OCnf8rc9VW
534GFt6BIYM8Ixqc5oOy6pGwzA3vuQ6V3kKOiTNNCvTar5YU9biayf2KI5TTtOo3
vneWtb2fsOSuOdySNBR4k8LxDvefpS36MSgEV4TYiixXx+fRVRg=
=nu3N
-----END PGP SIGNATURE-----
